home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Portable Patmos / usr / include / netiso / tp_tpdu.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-08  |  9.8 KB  |  295 lines  |  [TEXT/R*ch]

  1. /*-
  2.  * Copyright (c) 1991 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    from: @(#)tp_tpdu.h    7.4 (Berkeley) 5/6/91
  34.  *    $Id: tp_tpdu.h,v 1.3 1993/05/20 05:28:04 cgd Exp $
  35.  */
  36.  
  37. #ifndef _NETISO_TP_TPDU_H_
  38. #define _NETISO_TP_TPDU_H_
  39.  
  40. /***********************************************************
  41.         Copyright IBM Corporation 1987
  42.  
  43.                       All Rights Reserved
  44.  
  45. Permission to use, copy, modify, and distribute this software and its 
  46. documentation for any purpose and without fee is hereby granted, 
  47. provided that the above copyright notice appear in all copies and that
  48. both that copyright notice and this permission notice appear in 
  49. supporting documentation, and that the name of IBM not be
  50. used in advertising or publicity pertaining to distribution of the
  51. software without specific, written prior permission.  
  52.  
  53. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  54. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  55. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  56. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  57. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  58. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  59. SOFTWARE.
  60.  
  61. ******************************************************************/
  62.  
  63. /*
  64.  * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
  65.  */
  66. /* 
  67.  * ARGO TP
  68.  *
  69.  * This ghastly set of macros makes it possible to
  70.  * refer to tpdu structures without going mad.
  71.  */
  72.  
  73. #ifndef BYTE_ORDER
  74. /*
  75.  * Definitions for byte order,
  76.  * according to byte significance from low address to high.
  77.  */
  78. #define    LITTLE_ENDIAN    1234    /* least-significant byte first (vax) */
  79. #define    BIG_ENDIAN    4321    /* most-significant byte first (IBM, net) */
  80. #define    PDP_ENDIAN    3412    /* LSB first in word, MSW first in long (pdp) */
  81.  
  82. #ifdef vax
  83. #define    BYTE_ORDER    LITTLE_ENDIAN
  84. #else
  85. #define    BYTE_ORDER    BIG_ENDIAN    /* mc68000, tahoe, most others */
  86. #endif
  87. #endif BYTE_ORDER
  88.  
  89. /* This much of a tpdu is the same for all types of tpdus  (except
  90.  * DT tpdus in class 0; their exceptions are handled by the data
  91.  * structure below
  92.  */
  93. struct tpdu_fixed {
  94.     u_char            _tpduf_li:8,        /* length indicator */
  95. #if BYTE_ORDER == LITTLE_ENDIAN
  96.                 _tpduf_cdt: 4,        /* credit */
  97.                 _tpduf_type: 4;        /* type of tpdu (DT, CR, etc.) */
  98. #endif
  99. #if BYTE_ORDER == BIG_ENDIAN
  100.                 _tpduf_type: 4,        /* type of tpdu (DT, CR, etc.) */
  101.                 _tpduf_cdt: 4;        /* credit */
  102. #endif
  103.     u_short            _tpduf_dref;        /* destination ref; not in DT in class 0 */
  104. };
  105.  
  106. #define tpdu_li _tpduf._tpduf_li
  107. #define tpdu_type _tpduf._tpduf_type
  108. #define tpdu_cdt _tpduf._tpduf_cdt
  109. #define tpdu_dref _tpduf._tpduf_dref
  110.             
  111. struct tp0du {
  112.     u_char        _tp0_li,
  113.                 _tp0_cdt_type,        /* same as in tpdu_fixed */
  114. #if BYTE_ORDER == BIG_ENDIAN
  115.                 _tp0_eot: 1,        /* eot */
  116.                 _tp0_mbz: 7,        /* must be zero */
  117. #endif
  118. #if BYTE_ORDER == LITTLE_ENDIAN
  119.                 _tp0_mbz: 7,        /* must be zero */
  120.                 _tp0_eot: 1,        /* eot */
  121. #endif
  122.                 _tp0_notused: 8;    /* data begins on this octet */
  123. };
  124.  
  125. #define tp0du_eot _tp0_eot
  126. #define tp0du_mbz _tp0_mbz
  127.             
  128. /*
  129.  * This is used when the extended format seqence numbers are
  130.  * being sent and received. 
  131.  */
  132.                 /*
  133.                  * the seqeot field is an int that overlays the seq
  134.                  * and eot fields, this allows the htonl operation
  135.                  * to be applied to the entire 32 bit quantity, and
  136.                  * simplifies the structure definitions.
  137.                  */
  138. union seq_type {
  139.     struct {
  140. #if BYTE_ORDER == BIG_ENDIAN
  141.         unsigned int    st_eot:1,        /* end-of-tsdu */
  142.                          st_seq:31;        /* 31 bit sequence number */
  143. #endif
  144. #if BYTE_ORDER == LITTLE_ENDIAN
  145.         unsigned int    st_seq:31,        /* 31 bit sequence number */
  146.                         st_eot:1;        /* end-of-tsdu */
  147. #endif
  148.     } st;
  149.     unsigned int s_seqeot;
  150. #define s_eot    st.st_eot
  151. #define s_seq    st.st_seq
  152. };
  153.  
  154. /* Then most tpdu types have a portion that is always present but
  155.  * differs among the tpdu types :
  156.  */
  157. union  tpdu_fixed_rest {
  158.  
  159.         struct {
  160.             u_short        _tpdufr_sref,         /* source reference */
  161. #if BYTE_ORDER == BIG_ENDIAN
  162.                         _tpdufr_class: 4,    /* class [ ISO 8073 13.3.3.e ] */
  163.                         _tpdufr_opt: 4,        /* options [ ISO 8073 13.3.3.e ] */
  164. #endif
  165. #if BYTE_ORDER == LITTLE_ENDIAN
  166.                         _tpdufr_opt: 4,        /* options [ ISO 8073 13.3.3.e ] */
  167.                         _tpdufr_class: 4,    /* class [ ISO 8073 13.3.3.e ] */
  168. #endif
  169.                         _tpdufr_xx: 8;        /* unused */
  170.         } CRCC;
  171.  
  172. #define tpdu_CRli _tpduf._tpduf_li
  173. #define tpdu_CRtype _tpduf._tpduf_type
  174. #define tpdu_CRcdt _tpduf._tpduf_cdt
  175. #define tpdu_CRdref_0 _tpduf._tpduf_dref
  176. #define tpdu_CRsref _tpdufr.CRCC._tpdufr_sref
  177. #define tpdu_sref _tpdufr.CRCC._tpdufr_sref
  178. #define tpdu_CRclass _tpdufr.CRCC._tpdufr_class
  179. #define tpdu_CRoptions _tpdufr.CRCC._tpdufr_opt
  180.  
  181. #define tpdu_CCli _tpduf._tpduf_li
  182. #define tpdu_CCtype _tpduf._tpduf_type
  183. #define tpdu_CCcdt _tpduf._tpduf_cdt
  184. #define tpdu_CCdref _tpduf._tpduf_dref
  185. #define tpdu_CCsref _tpdufr.CRCC._tpdufr_sref
  186. #define tpdu_CCclass _tpdufr.CRCC._tpdufr_class
  187. #define tpdu_CCoptions _tpdufr.CRCC._tpdufr_opt
  188.  
  189. /* OPTIONS and ADDL OPTIONS bits */
  190. #define TPO_USE_EFC                 0x1
  191. #define TPO_XTD_FMT                 0x2
  192. #define TPAO_USE_TXPD             0x1
  193. #define TPAO_NO_CSUM             0x2
  194. #define TPAO_USE_RCC             0x4
  195. #define TPAO_USE_NXPD             0x8
  196.  
  197.         struct {
  198.             unsigned short _tpdufr_sref;    /* source reference */
  199.             unsigned char  _tpdufr_reason;    /* [ ISO 8073 13.5.3.d ] */
  200.         } DR;
  201. #define tpdu_DRli _tpduf._tpduf_li
  202. #define tpdu_DRtype _tpduf._tpduf_type
  203. #define tpdu_DRdref _tpduf._tpduf_dref
  204. #define tpdu_DRsref _tpdufr.DR._tpdufr_sref
  205. #define tpdu_DRreason _tpdufr.DR._tpdufr_reason
  206.  
  207.         unsigned short _tpdufr_sref;    /* source reference */
  208.  
  209. #define tpdu_DCli _tpduf._tpduf_li
  210. #define tpdu_DCtype _tpduf._tpduf_type
  211. #define tpdu_DCdref _tpduf._tpduf_dref
  212. #define tpdu_DCsref _tpdufr._tpdufr_sref
  213.  
  214.         struct {
  215. #if BYTE_ORDER == BIG_ENDIAN
  216.             unsigned char _tpdufr_eot:1,    /* end-of-tsdu */
  217.                           _tpdufr_seq:7;     /* 7 bit sequence number */
  218. #endif
  219. #if BYTE_ORDER == LITTLE_ENDIAN
  220.             unsigned char    _tpdufr_seq:7,     /* 7 bit sequence number */
  221.                             _tpdufr_eot:1;    /* end-of-tsdu */
  222. #endif
  223.         }SEQEOT;
  224.         struct {
  225. #if BYTE_ORDER == BIG_ENDIAN
  226.             unsigned int    _tpdufr_Xeot:1,        /* end-of-tsdu */
  227.                              _tpdufr_Xseq:31;    /* 31 bit sequence number */
  228. #endif
  229. #if BYTE_ORDER == LITTLE_ENDIAN
  230.             unsigned int    _tpdufr_Xseq:31,    /* 31 bit sequence number */
  231.                             _tpdufr_Xeot:1;        /* end-of-tsdu */
  232. #endif
  233.         }SEQEOT31;
  234.         unsigned int _tpdufr_Xseqeot;
  235. #define tpdu_seqeotX _tpdufr._tpdufr_Xseqeot
  236.  
  237. #define tpdu_DTli _tpduf._tpduf_li
  238. #define tpdu_DTtype _tpduf._tpduf_type
  239. #define tpdu_DTdref _tpduf._tpduf_dref
  240. #define tpdu_DTseq _tpdufr.SEQEOT._tpdufr_seq
  241. #define tpdu_DTeot _tpdufr.SEQEOT._tpdufr_eot
  242. #define tpdu_DTseqX _tpdufr.SEQEOT31._tpdufr_Xseq
  243. #define tpdu_DTeotX _tpdufr.SEQEOT31._tpdufr_Xeot
  244.  
  245. #define tpdu_XPDli _tpduf._tpduf_li
  246. #define tpdu_XPDtype _tpduf._tpduf_type
  247. #define tpdu_XPDdref _tpduf._tpduf_dref
  248. #define tpdu_XPDseq _tpdufr.SEQEOT._tpdufr_seq
  249. #define tpdu_XPDeot _tpdufr.SEQEOT._tpdufr_eot
  250. #define tpdu_XPDseqX _tpdufr.SEQEOT31._tpdufr_Xseq
  251. #define tpdu_XPDeotX _tpdufr.SEQEOT31._tpdufr_Xeot
  252.  
  253.         struct {
  254. #if BYTE_ORDER == BIG_ENDIAN
  255.             unsigned    _tpdufr_yrseq0:1,    /* always zero */
  256.                         _tpdufr_yrseq:31;     /* [ ISO 8073 13.9.3.d ] */
  257. #endif
  258. #if BYTE_ORDER == LITTLE_ENDIAN
  259.             unsigned    _tpdufr_yrseq:31,     /* [ ISO 8073 13.9.3.d ] */
  260.                         _tpdufr_yrseq0:1;    /* always zero */
  261. #endif
  262.             unsigned short _tpdufr_cdt; /* [ ISO 8073 13.9.3.b ] */
  263.         } AK31;
  264.  
  265. #define tpdu_AKli _tpduf._tpduf_li
  266. #define tpdu_AKtype _tpduf._tpduf_type
  267. #define tpdu_AKdref _tpduf._tpduf_dref
  268. #define tpdu_AKseq _tpdufr.SEQEOT._tpdufr_seq
  269. #define tpdu_AKseqX _tpdufr.AK31._tpdufr_yrseq
  270. /* location of cdt depends on size of seq. numbers */
  271. #define tpdu_AKcdt _tpduf._tpduf_cdt
  272. #define tpdu_AKcdtX _tpdufr.AK31._tpdufr_cdt
  273.  
  274. #define tpdu_XAKli _tpduf._tpduf_li
  275. #define tpdu_XAKtype _tpduf._tpduf_type
  276. #define tpdu_XAKdref _tpduf._tpduf_dref
  277. #define tpdu_XAKseq _tpdufr.SEQEOT._tpdufr_seq
  278. #define tpdu_XAKseqX _tpdufr.SEQEOT31._tpdufr_Xseq
  279.  
  280.         unsigned char _tpdu_ERreason;      /* [ ISO 8073 13.12.3.c ] */
  281.  
  282. #define tpdu_ERli _tpduf._tpduf_li
  283. #define tpdu_ERtype _tpduf._tpduf_type
  284. #define tpdu_ERdref _tpduf._tpduf_dref
  285. #define tpdu_ERreason _tpdufr._tpdu_ERreason
  286.  
  287. };
  288.  
  289. struct tpdu {
  290.     struct    tpdu_fixed         _tpduf;
  291.     union     tpdu_fixed_rest _tpdufr;
  292. };
  293.  
  294. #endif /* !_NETISO_TP_TPDU_H_ */
  295.